package com.zuxia.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.zuxia.entity.Bservice;
import com.zuxia.service.IBserviceService;

@Controller("bserviceAction")
@Scope("prototype")
@ParentPackage("json-default")
@Namespace("/")
@Results({
	@Result(name="findbserviceAll",type="dispatcher",location="/admin/bservice.jsp"),
	@Result(name="udpateBservice",type="redirectAction",location="/findbserviceAll"),
	@Result(name="saveBservice",type="redirectAction",location="/findbserviceAll"),
	@Result(name="json",type="json")
})
public class BserviceAction extends ActionSupport implements ModelDriven<Bservice> {

	private static final long serialVersionUID = 1L;
	
	private Bservice bservice = new Bservice();
	@Resource(name="bserviceService")
	private IBserviceService bserviceService;
	
	private Map<String,Object> map = new HashMap<String,Object>();
	private String bserviceIds;
	public Bservice getModel() {
		return bservice;
	}
	@Action("findbserviceAll")
	public String findbserviceAll() {//��ѯȫ��
		List<Bservice> bserviceList = bserviceService.findbserviceAll();
		map.put("bserviceList",bserviceList);
		return "findbserviceAll";
	}
	@Action("saveBservice")
	public String  saveBservice() {//���
		String reults = bserviceService.saveBservice(bservice);
		return reults;
	}
	@Action("deleteBservice")
	public String deleteBservice() {//����ɾ��
		Boolean b = bserviceService.deleteBservice(bservice);
		map.put("b",b);
		ActionContext.getContext().getValueStack().push(map);
		return "json";
	}
	@Action("findBserviceById")
	public String findBserviceById() {//��ѯ�������� �����޸Ļ���
		bservice = bserviceService.findBserviceById(bservice);
		map.put("bservice", bservice);
		ActionContext.getContext().getValueStack().push(map);
		return "json";
	}
	@Action("udpateBservice")
	public String udpateBservice() {//�޸�
		String result = bserviceService.udpateBservice(bservice);
		return result;
	}
	@Action("batcheDeleteBservice")
	public String batcheDeleteBservice() {//����ɾ��
		Boolean b = bserviceService.batcheDeleteBservice(bserviceIds);
		map.put("b", b);
		return "json";
	}
/*	@Action("findBservice")
	public String findBservice() {//
		List<Bservice> bserviceKing = bserviceService.findBserviceKing();
		map.put("bserviceKing",bserviceKing);
		return "json";
	}
	*/
	//------------------------------getter ------------------------------------setter----------------------------------
	public Map<String, Object> getMap() {
		return map;
	}
	public void setMap(Map<String, Object> map) {
		this.map = map;
	}
	public String getBserviceIds() {
		return bserviceIds;
	}
	public void setBserviceIds(String bserviceIds) {
		this.bserviceIds = bserviceIds;
	}
}
